package com.ruoyi.web.controller.video;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.userlike.domain.MyShortLike;
import com.ruoyi.userlike.service.IMyShortLikeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户行为表Controller
 * 
 * @author zunzun
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/userlike/userlike")
public class MyShortLikeController extends BaseController
{
    @Autowired
    private IMyShortLikeService myShortLikeService;

    /**
     * 查询用户行为表列表
     */
    @PreAuthorize("@ss.hasPermi('userlike:userlike:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyShortLike myShortLike)
    {
        startPage();
        List<MyShortLike> list = myShortLikeService.selectMyShortLikeList(myShortLike);
        return getDataTable(list);
    }

    /**
     * 导出用户行为表列表
     */
    @PreAuthorize("@ss.hasPermi('userlike:userlike:export')")
    @Log(title = "用户行为表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyShortLike myShortLike)
    {
        List<MyShortLike> list = myShortLikeService.selectMyShortLikeList(myShortLike);
        ExcelUtil<MyShortLike> util = new ExcelUtil<MyShortLike>(MyShortLike.class);
        util.exportExcel(response, list, "用户行为表数据");
    }

    /**
     * 获取用户行为表详细信息
     */
    @PreAuthorize("@ss.hasPermi('userlike:userlike:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(myShortLikeService.selectMyShortLikeById(id));
    }

    /**
     * 新增用户行为表
     */
    @PreAuthorize("@ss.hasPermi('userlike:userlike:add')")
    @Log(title = "用户行为表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyShortLike myShortLike)
    {
        return toAjax(myShortLikeService.insertMyShortLike(myShortLike));
    }

    /**
     * 修改用户行为表
     */
    @PreAuthorize("@ss.hasPermi('userlike:userlike:edit')")
    @Log(title = "用户行为表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyShortLike myShortLike)
    {
        return toAjax(myShortLikeService.updateMyShortLike(myShortLike));
    }

    /**
     * 删除用户行为表
     */
    @PreAuthorize("@ss.hasPermi('userlike:userlike:remove')")
    @Log(title = "用户行为表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(myShortLikeService.deleteMyShortLikeByIds(ids));
    }
}
